const fs = require('fs');
const path = require('path');
const selfsigned = require('selfsigned');

const attrs = [{
  name: 'commonName',
  value: 'localhost'
}];
const pems = selfsigned.generate(attrs, {
  algorithm: 'sha256',
  days: 365,
  keySize: 2048
});

fs.writeFileSync(path.join(__dirname, 'server.key'), pems.private);
fs.writeFileSync(path.join(__dirname, 'server.crt'), pems.cert);

console.log('SSL certificates generated successfully.');